package jeye.listeners.basic;

import jeye.events.MotionDetectionEvent;
import jeye.listeners.MotionDetectionListener;
import jeye.utils.FileUtils;

import org.apache.log4j.Logger;

public class CleanupListener implements MotionDetectionListener {
	
	private static final Logger LOG = Logger.getLogger(CleanupListener.class);

	public void onMotionDetection(MotionDetectionEvent motionDetectionEvent) {
		String eventUUID = motionDetectionEvent.getEventUUID();
		boolean success = FileUtils.deleteEventDir(eventUUID);
		
		LOG.debug("Removing event temp dir...");
		
		if(success) {
			LOG.debug("Removing event temp dir... completed.");
		}
		else {
			LOG.debug("Removing event temp dir... failed.");
		}
	}

}
